package com.smartrobot.smartrobot.util;

import java.io.File;


import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;
import android.widget.Toast;

import com.smartrobot.smartrobot.view.ToastCustom;


public class ImageUtil {
	
	public static int IMAGE_FROM_CAMMERA = 1000;
	public static int IMAGE_FROM_FILE = 1001;
	
	public static int IMAGE_FROM_CAMMERA_BUSINESS = 10011;
	public static int IMAGE_FROM_FILE_BUSINESS = 10012;
	
	public static int IMAGE_FROM_CAMMERA_IDENTIFY = 10013;
	public static int IMAGE_FROM_FILE_IDENTIFY = 10014;
	
	public static String getCameraPic(Activity activity,int flag) {
		
		Uri fileUri;
		String path;

		// 通过action获取图片
        try{
		Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
		File file = PictureFromCammera.getOutputMediaFile(1);
		fileUri = Uri.fromFile(file);
		path = file.getAbsolutePath();
		

		intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);


			activity.startActivityForResult(intent, flag);
			return path;
		}catch(Exception e){
			ToastCustom.showToast( activity.getApplicationContext(),"获取无法获得照相机图片");
			return null;
		}
		

	}
	
	public static void getDirPic(Activity activity,int flag){
		Intent intent=new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        intent.setType("image/*");
//        intent.setAction(Intent.ACTION_GET_CONTENT);
        try{
        	activity.startActivityForResult(intent, flag);
        }catch(Exception e){
        	ToastCustom.showToast(activity.getApplicationContext(),"请安装图片浏览器");
        }
	}
	

	

}
